home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 March / macformat-022.iso / Shareware City / Developers / SW Demo / Demo Source / InitMac.c < prev    next >
Encoding:
Text File  |  1994-11-08  |  2.6 KB  |  108 lines  |  [TEXT/MPCC]

  1. // ----------------------------------------------------------------------------------
  2. // InitMain.c
  3. // ----------------------------------------------------------------------------------
  4. // Initializes constants and the toolbox.
  5. //
  6. // ----------------------------------------------------------------------------------
  7. // History:
  8. //    8/26/94        Clark Goble    Original
  9. //
  10.  
  11. #include "EventLoop.h"
  12. #include "MenuHandler.h"
  13.  
  14. #define    _Unimplemented 0xA89F
  15. #define    _WaitNextEvent 0xA860
  16.  
  17. #include "Globals.h"
  18.  
  19. extern void ErrMsg(Str255 msg);
  20. extern Boolean TrapAvailable ( short tNum, short tType);
  21.  
  22. // ----------------------------------------------------------------------------------
  23. // WNEIsImplemented
  24. // ----------------------------------------------------------------------------------
  25. // Determines if we have WaitNextEvent available.
  26.  
  27. Boolean WNEIsImplemented( void )
  28. {
  29.     SysEnvRec    theWorld;
  30.     
  31.     SysEnvirons(1,&theWorld);
  32.     if (theWorld.machineType < 0)
  33.         return false;
  34.     else
  35.         return TrapAvailable ( _WaitNextEvent, ToolTrap);
  36. }
  37.  
  38. // ----------------------------------------------------------------------------------
  39. // BuildMenuBars
  40. // ----------------------------------------------------------------------------------
  41. // Creates the menus from a resource.
  42.  
  43. void BuildMenuBars(void)
  44. {
  45.     Handle theMenus;
  46.     
  47.     theMenus = GetNewMBar(128);
  48.     
  49.     if(theMenus) 
  50.     {    SetMenuBar(theMenus);
  51.         AddResMenu(GetMHandle(mApple),'DRVR');
  52.         
  53.         // AddResMenu(GetMHandle(mFont), 'FONT');
  54.         DrawMenuBar();
  55.         
  56.     } else 
  57.     {
  58.         ErrMsg("\pMenubar resouce not loaded.  Program will abort.");
  59.         ExitToShell();
  60.     }
  61. }
  62.  
  63. // ----------------------------------------------------------------------------------
  64. // InitToolBox
  65. // ----------------------------------------------------------------------------------
  66. // Initialize all the toolbox libraries.  You pass the number of master handle areas
  67. // that you need.  For a small app four should do.  If you have more handles, then
  68. // increase the number of Masters you use.
  69.  
  70. void InitToolBox(short numberOfMasters)
  71. {
  72.     SysEnvRec    envRec;        // Environment
  73.     
  74.     // Initialize Toolbox
  75.     InitGraf(&qd.thePort);
  76.     InitFonts();
  77.     InitWindows();
  78.     InitMenus();
  79.     InitCursor();
  80.     TEInit();
  81.     FlushEvents(everyEvent, 0);
  82.     InitDialogs(nil);
  83.     
  84.     // Initialize handles
  85.     while(numberOfMasters--)
  86.         MoreMasters();
  87.         
  88.     MaxApplZone();
  89.     
  90.     SysEnvirons(curSysEnvVers, &envRec);
  91.     
  92.     // We require at least a Mac+
  93.     if (envRec.machineType < 0)
  94.         ExitToShell();
  95.         
  96.     // Check to see if we are running System 7
  97.     gSys7 = (envRec.systemVersion >= 0x0700);
  98.  
  99.  
  100.     // Determine if we have WaitNextEvent
  101.     gHaveWNE = WNEIsImplemented();
  102.     InitCursor();
  103.     
  104.     gTextCurs = GetCursor(iBeamCursor);
  105.     HLock ((Handle) gTextCurs);
  106.     
  107. }
  108.